<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
    <link href="../../css/bootstrap.min.css" rel="stylesheet"/>
    <link href="../../css/font-awesome.css" rel="stylesheet"/>

    <!-- Data Tables -->
    <link href="../../css/style.css" rel="stylesheet"/>
    <link href="../../css/plugins/sweetalert/sweetalert.css" rel="stylesheet"/>

    <link href="../../css/animate.css" rel="stylesheet"/>
    <link href="../../css/style.css?v=4.1.0" rel="stylesheet"/>
    <style type="text/css">
        table, th{
            font-size: 18px;
            text-align: center;
        }
        *{
            font-size: 15px;
        }
    </style>
</h:head>
<h:body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox-title">
                    <h5>已选课程列表</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
                        </a> <a class="dropdown-toggle" data-toggle="dropdown"
                                href="table_basic.html#"> <i class="fa fa-wrench"></i>
                    </a> <a class="close-link"> <i class="fa fa-times"></i>
                    </a>
                    </div>
                </div>
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <h:form>
                            学生号:<h:inputText value="#{student.id}"/>
                            <h:commandButton class="btn btn-primary" action="#{course.getStudentCourseById(student.id)}" value="查询"/><br/>
                            课程号:<h:inputText value="#{course.id}" class="courseId"/>
                            <h:commandButton class="btn btn-primary" action="#{course.insertStudentCourse(student.id,course.id)}" value="增加"/>
                            <h:dataTable value="#{course.selectedCoursesList}" var="cour"
                                         cellspacing="0" cellpadding="10px" rules="all" border="4" frame="border" width="100%"
                                         rows="15" class="table table-striped table-bordered table-hover  dataTable">
                                <h:column>
                                    <f:facet name="header">编号</f:facet>
                                    <h:outputText value="#{cour.id}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">名称</f:facet>
                                    <h:outputText value="#{cour.name}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">学分</f:facet>
                                    <h:outputText value="#{cour.credit}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">任课教师</f:facet>
                                    <h:outputText value="#{cour.teacher}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">类别</f:facet>
                                    <h:outputText value="#{cour.category}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">时间</f:facet>
                                    <h:outputText value="#{cour.time}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">周次</f:facet>
                                    <h:outputText value="#{cour.week}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">上课地点</f:facet>
                                    <h:outputText value="#{cour.address}"/>
                                </h:column>
                                <h:column>
                                    <f:facet name="header">操作</f:facet>
                                    <h:commandButton class="btn btn-danger btn-sm"
                                                     action="#{course.deleteStudentCourse(student.id,cour.id)}" value="删除"/>
                                </h:column>
                            </h:dataTable>
                        </h:form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 全局js -->
    <script type="text/javascript" src="../../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../../js/select-course.js"></script>
    <script type="text/javascript" src="../../js/plugins/sweetalert/sweetalert.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            //第一次进入页面刷新一次，仅一次
            //location.href.indexOf("#")获取当前页面地址并在其中查找"#"首次出现位置，找不到就是-1
            if (location.href.indexOf("#") == -1) {
                //在当前页面地址加入"#"，使下次不再进入此判断
                location.href = location.href + "#";
                location.reload();
            }
            // 清空课程号
            $(".courseId").val("")
        })
    </script>
</h:body>

</html>
